package com.hk.core.authentication.security;

import com.hk.commons.JsonResult;
import com.hk.commons.Status;
import com.hk.core.web.Webs;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;


/**
 * @author kevin
 * @date 2019/12/16 14:15
 */
public record JsonAuthenticationEntryPoint() implements AuthenticationEntryPoint {

    @Override
    public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) {
        Webs.writeJson(response, HttpServletResponse.SC_OK, new JsonResult<>(Status.UNAUTHORIZED, "用户未认证"));
    }
}
